<?php
# ***** BEGIN LICENSE BLOCK *****
# This file is part of dcScrobbler for DotClear.
# Copyright (c) 2006-2007 Boris de Laage and contributors. All rights
# reserved.
#
# DotClear is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# DotClear is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with DotClear; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# ***** END LICENSE BLOCK *****

# $Id: _widgets.php 37 2007-01-19 18:49:44Z bdelaage $

$core->addBehavior('initWidgets',array('dcScrobblerBehavior','initWidgets'));
$core->addBehavior('pluginBeforeDelete',array('dcScrobblerBehavior','uninstall'));
/*
if ($core->blog->settings->get('add_to_post'))
	$core->addBehavior('adminBeforePostCreate', array('dcScrobblerBehavior','addToPost'));
//*/

class dcScrobblerBehavior
{
  public static function uninstall($plugin_id)
  {
    global $core;

    $core->blog->settings->setNameSpace('dcscrobbler');
    $tmp = array();
    foreach ($core->blog->settings->dumpSettings() as $k => $v)
      $tmp[$v['ns']][$k] = $v;
  
    foreach ($tmp as $ns => $s) {
      if ($ns === 'dcscrobbler')
        foreach ($s as $k => $v)
          $core->blog->settings->drop($k);
      $core->blog->triggerBlog();
    }
    
  }


  public static function initWidgets(&$widgets)
  {
    $widgets->create('dcscrobbler',__('Audioscrobbler'),
                     array('dcScrobblerWidget','widget'));

    $widgets->dcscrobbler->setting('title',__('Title:'),'');

    $widgets->dcscrobbler->setting('feed',__('Source:'),'rtracks','combo',
                                   array(__('Recent Tracks')  => 'recenttracks',
                                         __('Weekly Top Artists') => 'weeklyartistchart',
                                         __('Weekly Top Tracks')  => 'weeklytrackchart',
                                         __('Top Artists')    => 'topartists',
                                         __('Top Tracks')     => 'toptracks'));

    $widgets->dcscrobbler->setting('count',__('Limit (leave empty for no limit):'),'');
    $widgets->dcscrobbler->setting('showlogo',__('Show logo'),1,'check');
    $widgets->dcscrobbler->setting('homeonly',__('Home page only'),1,'check');
  }

/*  
  public static function addToPost(&$cur)
  {
	if ($cur->post_content)
	{
		$rt = dcScrobbler::getData('recenttracks',true);
		
		if ($rt) {
			$toto = $rt->track;
		}
		$cur->post_content .= "\n\n__Now playing :__" . $toto->date['uts'];
	}
  } //*/

}

?>